/**
 * Created by Administrator on 2022/8/21.
 */
/*class SuperClass {
    public String name;
    public String gender;
}
class SubClass extends SuperClass{
    public void fun() {
        name = "阿紫";
        gender = "女";
        System.out.println("姓名："+name);
        System.out.println("性别："+gender);
    }
}
public class Test {
    public static void main(String[] args) {
        SubClass sub = new SubClass();
        sub.fun();
    }
}*/


/*class SuperClass {
   public void print1() {
       System.out.println("SuperClass");
   }
}
class SubClass extends SuperClass{
    public void print2() {
        System.out.println("SubClass");
    }

    public void demo() {
        print1();
        print2();
    }
}
public class Test {
    public static void main(String[] args) {
        SubClass sub = new SubClass();
        sub.demo();
    }
}*/

class SuperClass {
   public void print1() {
       System.out.println("SuperClass1");
   }
    public void print2() {
        System.out.println("SuperClass2");
    }
}
class SubClass extends SuperClass{
    public void print1() {
        System.out.println("SubClass1");
    }
    public void print2(int a) {
        System.out.println("SubClass2");
    }
    public void demo() {
        print1();// 直接访问，则永远访问到的都是子类中的print1()，基类的无法访问到
        print2();// 没有传参，访问的则是基类的print2()
        print2(1);// 传参了，访问的则是子类的print2(int a)
    }
}
public class Test {
    public static void main(String[] args) {
        SubClass sub = new SubClass();
        sub.demo();
    }
}